layui.use(['form', 'layer', 'table'], function () {
    const form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        table = layui.table;

    //列表
    const tableIns = table.render({
        elem: '#list',
        url: $.cookie("tempUrl") + 'information/selectList',
        where: {token: $.cookie("token")},
        method: "GET",
        request: {
            pageName: 'pageNum' //页码的参数名称，默认：page
            , limitName: 'pageSize' //每页数据量的参数名，默认：limit
        },
        response: {
            statusName: 'code' //数据状态的字段名称，默认：code
            , statusCode: 0 //成功的状态码，默认：0
            , msgName: 'httpStatus' //状态信息的字段名称，默认：msg
            , countName: 'totalElements' //数据总数的字段名称，默认：count
            , dataName: 'content' //数据列表的字段名称，默认：data
        },
        cellMinWidth: 95,
        page: true,
        height: "full-25",
        limits: [5, 10, 15, 20, 25],
        limit: 15,
        id: "dataTable",
        // toolbar: '#toolbarDemo',
        // defaultToolbar: [],
        cols: [[
            {type: "checkbox", fixed: "left", width: 50},
            {field: 'id', title: 'ID', width: 90, align: 'center'},
            {field: 'introduction', title: '患者姓名', minWidth: 90, align: 'center'},
            {
                field: 'introduction', title: '患者性别', minWidth: 90, align: 'center', templet: function (d) {
                    if (d.status === 1) {
                        return '男';
                    } else if (d.status === 2) {
                        return '女';
                    }
                }
            },
            {field: 'introduction', title: '患者年龄', minWidth: 90, align: 'center'},
            {
                field: 'createDate', title: '订单时间', width: 200, align: "center", templet: function (d) {
                    return d.createDate;
                }
            },
        ]]
    });


    //批量删除
    $(".delAll_btn").click(function () {
        var checkStatus = table.checkStatus('dataTable'),
            data = checkStatus.data,
            newsId = [];
        if (data.length > 0) {
            for (var i in data) {
                newsId.push(data[i].id);
            }
            layer.confirm('确定删除选中的文章？', {icon: 3, title: '提示信息'}, function (index) {
                $.ajax({
                    url: $.cookie("tempUrl") + "article/articleDelSome?token=" + $.cookie("token") + "&ids=" + newsId + "&handler=" + $.cookie("truename"),
                    type: "DELETE",
                    success: function (result) {
                        layer.msg(result.data);
                        window.location.href = "articleList.html";
                    }
                });
                tableIns.reload();
                layer.close(index);
            })
        } else {
            layer.msg("请选择需要删除的文章");
        }
    })

});
